home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_400 / 424_02 / ED-157 / move_eol.c < prev    next >
C/C++ Source or Header  |  1993-09-10  |  2KB  |  70 lines

  1. /*
  2.  * Copyright (C) 1992 by Rush Record (rhr@clio.rice.edu)
  3.  * 
  4.  * This file is part of ED.
  5.  * 
  6.  * ED is free software; you can redistribute it and/or modify it under the terms
  7.  * of the GNU General Public License as published by the Free Software Foundation.
  8.  * 
  9.  * ED is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  10.  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  11.  * PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  12.  * 
  13.  * You should have received a copy of the GNU General Public License along with ED
  14.  * (see the file COPYING).  If not, write to the Free Software Foundation, 675
  15.  * Mass Ave, Cambridge, MA 02139, USA.
  16.  */
  17. #include "opsys.h"
  18.  
  19. #include <string.h>
  20.  
  21. #include "rec.h"
  22. #include "window.h"
  23. #include "ed_dec.h"
  24.  
  25. /******************************************************************************\
  26. |Routine: move_eol
  27. |Callby: edit
  28. |Purpose: Moves the cursor to the ends of records.
  29. |Arguments:
  30. |    repeat is the number of records to move the cursor.
  31. \******************************************************************************/
  32. void move_eol(repeat)
  33. register Int repeat;
  34. {
  35.     if(DIRECTION > 0)
  36.         while(repeat-- > 0)
  37.         {
  38.             if(CURREC == BASE)
  39.             {
  40.                 CURBYT = 0;
  41.                 abort_key();
  42.                 break;
  43.             }
  44.             if(CURBYT == CURREC->length)
  45.             {
  46.                 CURREC = CURREC->next;
  47.                 CURBYT = CURREC->length;
  48.                 CURROW++;
  49.             }
  50.             else
  51.                 CURBYT = CURREC->length;
  52.         }
  53.     else    /* direction is backwards */
  54.         while(repeat-- > 0)
  55.         {
  56.             if(CURREC->prev == BASE)
  57.             {
  58.                 abort_key();
  59.                 break;
  60.             }
  61.             CURREC = CURREC->prev;
  62.             CURBYT = CURREC->length;
  63.             CURROW--;
  64.         }
  65.     CURCOL = get_column(CURREC,CURBYT);
  66.     WANTCOL = CURCOL;
  67.     fix_display();
  68. }
  69.  
  70.